package org.lds.simple.disruptor.util;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

public class Util {
    private static final Unsafe THE_UNSAFE;

    static {
        try {
            Field field = Unsafe.class.getDeclaredField("theUnsafe");
            field.setAccessible(true);
            THE_UNSAFE = (Unsafe) field.get(null);
        } catch (Exception e) {
            throw new RuntimeException("THE_UNSAFE load fail");
        }
    }

    public static Unsafe getUnsafe() {
        return THE_UNSAFE;
    }
}
